package pl.poznan.put.cs.idss.students.coolring;

import java.util.logging.Logger;

import pl.poznan.put.cs.idss.students.coolring.i18n.Messages;
import pl.poznan.put.cs.idss.students.coolring.properties.Properties;
import pl.poznan.put.cs.idss.students.coolring.ui.GeneralWindow;
import pl.poznan.put.cs.idss.students.coolring.ui.SplashScreen;

/**
 * Główna klasa programu - odpowiada za załadowanie i wyświetlenie okna
 * programu.
 * 
 * @author Kornel Lewandowski
 * 
 */
public class Main {

	private static SplashScreen splashScreen;
	private static GeneralWindow appWindow;

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Logger log = Logger
				.getLogger("pl.poznan.put.cs.idss.students.kingcart");

		log.info(Messages.get("UI.application_name") + " "
				+ Messages.get("UI.application_version"));
		log.info(Messages.get("UI.application_description"));

		try {
			splashScreen = new SplashScreen(
					Properties.number("splashscreen_duration"));
			appWindow = new GeneralWindow();
		} catch (Exception e) {
			log.severe("Splash screen error - see stacktrace");
			e.printStackTrace();
			return;
		}

		if (splashScreen.isTimeUp() && appWindow.isReady()) {
			appWindow.showWindow();
			splashScreen.dispose();
		} else {
			log.severe("Splash screen cannot be closed or general window cannot be shown");
			return;
		}

	}

}
